package com.qx.pethome.dao.impl;

import com.mysql.cj.jdbc.JdbcConnection;
import com.qx.pethome.dao.AdministratorDao;
import com.qx.pethome.entity.Administrator;
import com.qx.pethome.util.JDBCUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Timestamp;

public class AdministratorDaoImpl implements AdministratorDao {

    /**
     * 管理员管理层的实现
     */

    public void insertDao(Administrator administrator) throws Exception {
        Connection conn = JDBCUtils.getConnection();
        String sql = "insert into Administrator(admId,admName,admSex,admAge,admPhone,admEmail,admStatus,admTime,admPassword) values (default,?,?,?,?,?,?,?,?)";
        PreparedStatement pst = conn.prepareStatement(sql);
        pst.setString(1,administrator.getAdmName());
        pst.setBoolean(2,administrator.getAdmSex());
        pst.setInt(3,administrator.getAdmAge());
        pst.setString(4,administrator.getAdmPhone());
        pst.setString(5,administrator.getAdmEmail());
        pst.setInt(6,administrator.getAdmStatus());
        pst.setTimestamp(7,new Timestamp(administrator.getAdmTime().getTime()));
        pst.setString(8,administrator.getAdmPassword());
        pst.executeUpdate();
        JDBCUtils.close(conn,pst);
    }

    @Override
    public void deleteDao(Administrator administrator) throws Exception {
       Connection connection = JDBCUtils.getConnection();
        String sql = "insert into Administrator(admId,admName,admSex,admAge,admPhone,admEmail,admStatus,admTime,admPassword) values (default,?,?,?,?,?,?,?,?)";
    }

    @Override
    public void updateDao(Administrator administrator) throws Exception {

    }

    @Override
    public void selectDao(Administrator administrator) throws Exception {

    }

}
